using Sustainalytics.ESG.Entities;
using Sustainalytics.Synchronization.Validation.ValidationRules.Common;

namespace Sustainalytics.Synchronization.Validation.ValidationRules.Comprehensive
{
    public class ScoreChangeRedRule : ComprehensivePercentChangeBetween<RPCompanyESGComputationResult>
    {
        public override Severity Severity => Severity.Red;
        public override BusinessResearchProduct BusinessResearchProduct => BusinessResearchProduct.Comprehensive;
        public override string Code => "RR3";
        public override string InformationalMessage => "Change in Overall ESG Score is above 50%";

        public ScoreChangeRedRule()
            : base(0.5)
        {
            For(x => x.OverallPerformance.Score).When((validatedEntity, referenceEntity) => !Validator(validatedEntity, referenceEntity))
                .WithKey(x => x.Id)
                .WithMessage("The company {0} #{1}# has overall score changes higher than 50%");
        }
    }
}
